﻿using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace My.Application.Contracts.Orders.Dtos
{
    public class CreateOrderDtoValidator : AbstractValidator<CreateOrderDto>
    {
        public CreateOrderDtoValidator()
        {
            RuleForEach(o => o.OrderLines).SetValidator(new CreateOrderLineDtoValidator());
        }
    }

    public class CreateOrderLineDtoValidator : AbstractValidator<CreateOrderLineDto>
    {
        public CreateOrderLineDtoValidator()
        {
            RuleFor(x => x.ProductId).NotEqual(new Guid()).WithMessage("产品id不能为空");
            RuleFor(x => x.Count).GreaterThan(0).WithMessage("产品数量应大于0");
        }
    }
}
